package entity

//import service.activity.ActivityInfo
import org.hibernate.annotations.NotFound
import org.hibernate.annotations.NotFoundAction
import service.activity.ActivityInfo
import javax.persistence.*

//@Entity
//@Table(name = "tb_activity")
public class Activity {
    fun setInfo(activityInfo: ActivityInfo) {
        activityInfo.let {
            this.activityName = it.name
            this.activityProfile = it.profile ?: ""
            this.startTime = it.startTime ?: 0
            this.endTime = it.endTime ?: 0
            this.activityType = it.activityType.toString()
            this.location = it.location ?: ""
            this.activityPic = it.activityPic ?: ""
        }
    }

    //    @Id
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Int = -1

    //活动id
//    @Column(name = "a_code")
    var activityCode: String = ""

    //活动名称
//    @Column(name = "a_name")
    lateinit var activityName: String

    //活动简介
//    @Column(name = "a_profile")
    lateinit var activityProfile: String

    //活动开始时间戳
//    @Column(name = "a_start")
    var startTime: Long = -1

    //活动结束时间戳
//    @Column(name = "a_end")
    var endTime: Long = -1

    //活动类型
//    @Enumerated(EnumType.STRING)
//    @Column(name = "a_type")
    var activityType = ActivityType.OTHERS.toString()

    //位置
//    @Column(name = "a_location")
    var location = ""

    //活动图片
//    @Column(name = "a_pic")
    var activityPic = ""

    //    @OneToMany(cascade = [CascadeType.MERGE])
//    @NotFound(action = NotFoundAction.IGNORE)
//    @JoinColumn(name = "activity_id")
    var banners: Set<Banner>? = HashSet()

    //    @Column(name = "publish_time")
    var publishTime = -1L

    //活动审核状态
//    @Column(name = "isChecked")
    var checked: Boolean? = null

    // 该活动的发布人
//    @ManyToOne
//    @JoinColumn(name = "publisher_id")
    lateinit var publisher: User

    // 该活动的审核人
//    @ManyToOne
//    @JoinColumn(name = "examiner_id")
    lateinit var examiner: User

    override fun toString(): String {
        return "Activity(id=$id, activityCode='$activityCode', activityName='$activityName', activityProfile='$activityProfile', startTime=$startTime, endTime=$endTime, activityType='$activityType', location='$location', publishTime=$publishTime, checked=$checked, publisher=$publisher, examiner=$examiner)"
    }

//    override fun toString(): String {
//        return "Activity(id=$id, activityCode='$activityCode', activityName='$activityName', activityProfile='$activityProfile', startTime=$startTime, endTime=$endTime, activityType='$activityType', checked=$checked)"
//    }


}

//活动类型枚举类
enum class ActivityType {
    STUDY,
    PLAY,
    SPORTS,
    READING,
    OTHERS
}
